825A - Binary Protocol - CodeForces Solution


implementation *1100

Please click on ads to support us..

C++ Code:

// 1677685109140
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define f(i, x, n) for (int i = x; i < n; ++i)
#define rf(i, x, n) for (int i = x; i >= n; --i)
#define fr(i, m) for (auto &i : m)
#define pl pair<long long, long long>
#define vl vector<long long>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rll(v) (v).begin(), (v).end(), greater<ll>()
#define si size()
#define lcm(a, b) ((a * b) / (__gcd(a, b)))

#define time_nhi_hai ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
long double fast_pow(long double a, int p)
{
    long double ret = 1.;
    for (; p; p /= 2, a *= a)
        if (p & 1)
            ret *= a;
    return ret;
}
bool isprime(ll number)
{
    if (number <= 1)
        return false;
    if (number == 2)
        return true;
    if (number % 2 == 0)
        return false;
    int boundary = (int)floor(sqrt(number));
    for (int i = 3; i <= boundary; i += 2)
        if (number % i == 0)
            return false;
    return true;
}
ll power(ll a, ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        b = b / 2;
    }
    return ans;
}
vector<int> Sieve(int n)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for (int p = 2; p * p <= n; p++)
    {
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    vector<int> vec;
    for (int p = 2; p <= n; p++)
        if (prime[p])
            vec.push_back(p);
    return vec;
}

int main()
{
    time_nhi_hai;

    ll n, m;
    string s;

    cin >> n >> s;

    ll k = 0;
    for (ll i = 0; i < n; i++)
    {
        if (s[i] == '1')
            k++;

        else
        {
            cout << k;
            k = 0;
        }
    }

    cout << k;
}


Comments

Submit
0 Comments
More Questions

1302. Deepest Leaves Sum
1209. Remove All Adjacent Duplicates in String II
994. Rotting Oranges
983. Minimum Cost For Tickets
973. K Closest Points to Origin
969. Pancake Sorting
967. Numbers With Same Consecutive Differences
957. Prison Cells After N Days
946. Validate Stack Sequences
921. Minimum Add to Make Parentheses Valid
881. Boats to Save People
497. Random Point in Non-overlapping Rectangles
528. Random Pick with Weight
470. Implement Rand10() Using Rand7()
866. Prime Palindrome
1516A - Tit for Tat
622. Design Circular Queue
814. Binary Tree Pruning
791. Custom Sort String
787. Cheapest Flights Within K Stops
779. K-th Symbol in Grammar
701. Insert into a Binary Search Tree
429. N-ary Tree Level Order Traversal
739. Daily Temperatures
647. Palindromic Substrings
583. Delete Operation for Two Strings
518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST